package com.suntront.lib_db.table;



import com.suntront.lib_db.utils.FileUtils;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import com.suntront.lib_db.utils.Utils;

/**
 * Created by MSI1 on 2017/3/7.
 */
@Entity(tableName = "ErrorT")
public class ErrorT {

    /**
     * public int UserInfoID;//用户id
     * public string UserInfoCode;//户号
     * public string UserName;//户名
     * public string remark;//异常信息
     * public int meterreaderid;//抄表员id
     * public string cadminname;//抄表员姓名
     * public DateTime uploadtime;//上传时间
     * public string image;//照片流
     */
    @PrimaryKey(autoGenerate = true)
    private int id;
    @ColumnInfo(name = "isUp")
    private boolean isUp;
    @ColumnInfo(name = "UserInfoID")
    private int UserInfoID;
    @ColumnInfo(name = "UserInfoCode")
    private String UserInfoCode;
    @ColumnInfo(name = "UserName")
    private String UserName;
    @ColumnInfo(name = "remark")
    private String remark;
    @ColumnInfo(name = "meterreaderid")
    private int meterreaderid;
    @ColumnInfo(name = "cadminname")
    private String cadminname;
    @ColumnInfo(name = "uploadtime")
    private String uploadtime;
    @ColumnInfo(name = "image")
    private String image;

    public String getUpError() {
        String[] images;
        if (image != null) {
            images = image.split("[&]");
        } else {
            images = null;
        }

        String base64 = null;
        if (images != null && images.length != 0) {
            for (String img : images) {
                String s = Utils.compressImage(img, img, 30);
                if (base64 == null) {
                    base64 = "data:image/png;base64," + FileUtils.imgToBase64(s);
                } else {
                    base64 = base64 + "&" + "data:image/png;base64," + FileUtils.imgToBase64(s);
                }
            }
        }

        return "[{" +
                "\"" + "UserInfoID" + "\"" + ":" + UserInfoID +
                ",\"" + "UserInfoCode" + "\"" + ":" + "\"" + UserInfoCode + "\"" +
                ",\"" + "UserName" + "\"" + ":" + "\"" + UserName + "\"" +
                ",\"" + "remark" + "\"" + ":" + "\"" + remark + "\"" +
                ",\"" + "cadminname" + "\"" + ":" + "\"" + cadminname + "\"" +
                ",\"" + "uploadtime" + "\"" + ":" + "\"" + uploadtime + "\"" +
                ",\"" + "meterreaderid" + "\"" + ":" + meterreaderid +
                ",\"" + "image" + "\"" + ":" + "\"" + base64 + "\"" + "}]";
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public boolean isUp() {
        return isUp;
    }

    public void setUp(boolean up) {
        isUp = up;
    }

    public int getUserInfoID() {
        return UserInfoID;
    }

    public void setUserInfoID(int userInfoID) {
        UserInfoID = userInfoID;
    }

    public String getUserInfoCode() {
        return UserInfoCode;
    }

    public void setUserInfoCode(String userInfoCode) {
        UserInfoCode = userInfoCode;
    }

    public String getUserName() {
        return UserName;
    }

    public void setUserName(String userName) {
        UserName = userName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getMeterreaderid() {
        return meterreaderid;
    }

    public void setMeterreaderid(int meterreaderid) {
        this.meterreaderid = meterreaderid;
    }

    public String getCadminname() {
        return cadminname;
    }

    public void setCadminname(String cadminname) {
        this.cadminname = cadminname;
    }

    public String getUploadtime() {
        return uploadtime;
    }

    public void setUploadtime(String uploadtime) {
        this.uploadtime = uploadtime;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }


}
